@isTest
private class InstrumentScrappingHandlerTest {


    static testMethod void  testMethod1() {

    	  Id ldcProfile1 = [Select Id,Name From Profile Where Name like '%工程部%' limit 1 ].Id;
        User u1 = new User( Alias = 'samLdc1', 
                         Email = 'ldc@test.com.maike',
                         Emailencodingkey = 'UTF-8', 
                         Lastname = '用户1', 
                         Languagelocalekey = 'en_US',
                         Localesidkey = 'en_US', 
                         Profileid = ldcProfile1, 
                         Country = 'United States',
                         companyName = 'Y-MKSY',
                         IsActive = true,
                         SubCompany__c='四川省迈克实业有限公司',
                         UserDepartment__c='客户服务中心(工程部)',
                         Timezonesidkey = 'America/Los_Angeles', 
                         EmployeeNumber = '123451',
                         managerId = UserInfo.getUserId(),
                         FederationIdentifier = '3451',
                        
                         Username = 'Matldc1@test.com.maike');
        insert u1;

        Account acc = TestUtils.createAccount();
        insert acc;

        ProductStructure__c ps1=new ProductStructure__c();
        ps1.Name='仪器';
        ps1.Classify1__c='生化';
        ps1.Classify2__c='生化-设备';
        ps1.Classify3__c='仪器';
        insert ps1;
          Brand__c brand = new Brand__c(
            BrandShortName__c = '四川迈克'
        );
        insert brand;
         //产品
        Product__c p1=TestUtils.createProduct();
        p1.Name='仪器';
        p1.Category0__c = '仪器';
        p1.Model__c='Model1228';
        p1.ProductStructure__c=ps1.Id;
        p1.CRMBrand__c = brand.Id;
        p1.RecordTypeId =  Utils.getRecordTypeIdByDevNameAndObjName('NCProduct','Product__c');
        insert p1;

        Price__c pr1 = new Price__c(
            Product__c = p1.Id,
            Company__c = '四川省迈克实业有限公司',
            CompanyBottomPrice__c = 1.0,
            HospitalBottomPrice__c = 1.0,
            InvoiceDealerPrice__c = 1.0,
            AreaDealerPrice__c = 1.0,
            MarketPrice__c = 1.0,
            HospitalManagerPrice__c= 1.0,
            InstCost__c = 0.5
            
        );
        insert pr1;


        Equipment__c e1 = new Equipment__c();
        e1.Account__c = acc.Id;
        e1.IMEINumber__c = '11';
        e1.Product__c = p1.Id;
        insert e1;
       	User u = new User(Id = UserInfo.getUserId() );
       	u.BiochemicalImmunityPD__c = u1.Id;
       	u.BiochemicalImmunityPM__c = u1.Id;
       	u.BloodSugarPD__c = u1.Id;
       	u.BloodPM__c = u1.Id;
       	u.BloodTypePM__c = u1.Id;
       	u.PathologyPD__c = u1.Id;
       	u.BiochemicalIPM__c = u1.Id;
       	u.ImmunityPM__c = u1.Id;
       	u.ClinicalLaboratoryPM__c = u1.Id;
       	u.ClinicalLaboratoryPD__c = u1.Id;
       	u.EngineeringSupervisor__c = u1.Id;
       	u.SubCompanyManager__c = u1.Id;
       	u.FinancialCenterManager__c = u1.Id; 


       	update u ; 

        InstrumentScrapping__c ins = new InstrumentScrapping__c();
        ins.ScrapInstrument__c = e1.Id;
        ins.Status__c = '草案中';
        //sins.Account__c = acc.Id;
        insert ins;

        ins.Status__c = '已批准';
        update ins;

    }

}